import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


@WebServlet("/getParameter")
// Parameter 参数
public class GetQueryStringParameterServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 此处约定 请求中的 query string 形如: useName=zhangshan&passWord=123
        // query string 会被 tomcat 解析成类似于 Map 的结构
        String userName = req.getParameter("useName");
        String passWord = req.getParameter("passWord");

        // 打印
        System.out.println("useName=" + userName);
        System.out.println("passWord" + passWord);

        resp.getWriter().write("OK!");
    }
}
